<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>hello world</title>
    <script src="../libs/vue/2.6.11/vue.min.js"></script>
</head>
<body>
<div id="app">
    <label>添加：</label><input type="text" v-on:keydown.13="add" ref="text_input"></input>
    <ul>
        <li v-for="item in items">
            <h3>{{item.title}}</h3>
            <p>{{item.description}}</p>
        </li>
    </ul>
</div>
<script>
    var vm = new Vue({
            el: '#app',
            data: {
                items: [
                    {title: '《唐诗三百首》', description: '劝君更进一杯酒，西出阳关无故人'},
                    {title: '《诗经》', description: '窈窕淑女，君子好逑'},
                    {title: '《宋词》', description: '稻花香里说丰年，听取蛙声一片'},
                    {title: '《元曲》', description: '快使用双节棍，哼哼哈嘿'}
                ]
            },
            methods: {
                add: function (event) {
                    console.log(event)
                    var name = this.$refs.text_input.value;
                    this.items.push({title: name, description: '快使用双节棍，哼哼哈嘿'})
                }
            }
        })
</script>
</body>
</html>